package com.knight;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by qiangjindong
 * 2018-08-25 12:10
 */
public class KnightMain {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = (ClassPathXmlApplicationContext) wireFromXml();
        BraveKnight knight = context.getBean(BraveKnight.class);
        knight.embarkOnQuest();
        context.close();
    }

    public static ApplicationContext wireFromXml() {
        return new ClassPathXmlApplicationContext("spring/minstrel.xml");
    }

    public static ApplicationContext wireFromJavaConfig() {
        return new AnnotationConfigApplicationContext(KnightConfig.class);
    }
}
